package com.yt.web.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lombok.Data;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yt.service.UserService;

@Controller
public class IndexController {

	@Autowired
	private UserService userService;
	
	@RequestMapping("/index")
	public String Index(HttpServletRequest req,HttpServletResponse res,ModelMap modelMap){
			
		List<String> list = new ArrayList<String>();
        list.add("one");
        list.add("two");
        list.add("three");
		modelMap.put("list",list);
		
		return "index";
	}
	
	@RequestMapping("/getUser")
	public String getUser(HttpServletRequest req,HttpServletResponse res,ModelMap modelMap){
		Integer userId = Integer.parseInt(req.getParameter("id"));
		String name =  userService.getName(userId);
		modelMap.put("uid", userId);
		modelMap.put("name", name);
		return "getUser";
	}
	
}
